package com.vert.auth.service.impl;

import com.vert.annotations.Autowired;
import com.vert.annotations.Service;
import com.vert.auth.model.UserModel;
import com.vert.auth.service.UserModelService;
import com.vert.db.SqlBuilder;
import com.vert.db.TableService;
import com.vert.db.model.IPage;

/**
 * @Classname UserModelServiceImpl
 * @Description TODO
 * @Date 2022/6/2 12:52
 * @Created by XiongXiong
 * @Author: X.I.O
 */
@Service
public class UserModelServiceImpl implements UserModelService {

    @Autowired
    private TableService tableService;

    @Override
    public UserModel saveUserModel(UserModel userModel) {
      return null;
    }

    @Override
    public UserModel getUserModel(String username) {
        SqlBuilder sqlBuilder=tableService.getSqlBuilder(UserModel.class);
        sqlBuilder.and("username").eq(username);
        return tableService.selectOne(sqlBuilder,UserModel.class);
    }

    @Override
    public IPage<UserModel> getUserModelPage(int pageNum, int pageSize) {
      SqlBuilder sqlBuilder=tableService.getSqlBuilder(UserModel.class);
      sqlBuilder.page(pageNum,pageSize);
      return tableService.getPage(sqlBuilder,UserModel.class);
    }
}
